import router from "@/router";
import store from "@/store";

router.beforeEach((to, from, next) => {
  // 去往非登录页 + 已登录
  if (to.path !== "/login" && store.state.isLogin === true) {
    console.log(to.path);
    next();
  }
  //   去往非登录页 + 未登录
  else if (to.path !== "/login" && store.state.isLogin === false) {
    next({ path: "/login" });
  }
  //   去往登录页
  else if (to.path === "/login") {
    next();
  }
});
